#pragma once
//#include "datamanager.h"
#include "gangia_gui.h"
//#include "gangiaconfig.h"
#include "./Plot/plot.h"
#include <BaseAlgoConfig.h>
#include	<BCIStructs.h>
#include "MA_IIR_Filter.h"
//#include "gangiaplotcurve.h"
#pragma once
#include ".\Devices\Instrument.h"
class Instrument;

#define	REDRAW_INTERVAL	50

//typedef enum SpatialFilter

#define LINEAR		1
#define CAR			2
#define LAPLACIAN	3
#define BIPOLAR		4

class PlotFrameHandler :	public PlotFrame
{
public:
	
	PlotFrameHandler(wxWindow *parent, int id,int PlotsNumber,wxString *pLabels, int SampleFreq, int PlotSeconds,float *Max,float *Min, Instrument *pinstrument );
	//void RegisterPlots(int Kind);
	void RefreshUI(wxTimerEvent& Event);
public:
	void	OnResize(wxSizeEvent& event);
	void	OnChangeLead(wxCommandEvent& Event);
	void	OnChangeFilter(wxCommandEvent& Event);
	void	OnChannelNumber( wxSpinEvent& event );
	void	OnPlay(wxCommandEvent& Event);
	void	OnFreeze(wxCommandEvent& Event);
	void	OnSetPlotProperties( wxMouseEvent& event );
	void	PutSample(SampleStruct Sample);
	void	SetAcqInfo(AcqInfo Inf)
	{
		Info = Inf;
	}
	void	SetTextPtr(wxStaticText *pFreq, wxStaticText *pTime, wxStaticText *pSample, wxStaticText *pError)
	{
		mySampleFreq = pFreq;
		mySample = pSample;
		myError = pError;
		myElapTime = pTime;
	}
	void	OnIdle( wxIdleEvent& event );
	void	Scroll(wxScrollEvent& event)
	{
		event.Skip();
	}
	void	OnChangePage( wxCommandEvent& event );
	void	OnTrigger(wxCommandEvent& event);
	void	OnHide(wxCommandEvent& event);
	void	OnShow(wxCommandEvent& event);
	void	SetPages();
	void	RegisterPlots();
	void CleanPlot(void);
	
	~PlotFrameHandler(void);
	wchar_t *yLabel;
	bool isRunning;
protected:
	int		PlotsPerPage;
	void	SelectCurve(int Index);
	void	OnZoomIn ( wxCommandEvent& event );
	void	OnZoomOut ( wxCommandEvent& event );
	void	OnKeyDown ( wxKeyEvent& event );
	Instrument *pNavigator;

	//void OnReshape(wxCommandEvent& Event);
	void StartDrawing(void);

	DECLARE_EVENT_TABLE();

	
	int				CurrentSpatialFilter,PlotLength;
	float			Frequency;
	AcqInfo			Info;
	wxTimer			Timer;

	MA_IIR_Filter	Filter;
	
	int				CurveCount,Pages;
	double			X[2],Y[2];
//	wxPlotData		*pTheCursor;
	Plot			*m_SigPlot;
	SignalClass		*pChLin[MAX_CHANNELS];
	bool			RegsCurves[MAX_CHANNELS];
	wxString		*ChLabels;
	wxSemaphore		RedrawSema;
	int				TheoreticalFrequency,PlotSecondsPerPage;
	wxStaticText	*myElapTime;
	wxStaticText	*mySampleFreq;
	wxStaticText	*mySample;
	wxStaticText	*myError;
	wxStaticText	*myProc2;
	wxStaticText	*myProc3;
	
};




